package com.tenxun.test;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

@SpringBootTest
public class jdbcselect {
    //创建数据源
    @Qualifier("dataSource")
    @Autowired
    private DataSource dataSource;

    @Test
    void insertgo() throws SQLException {
        //通过数据源获取连接
        Connection con = dataSource.getConnection();
        //创建对象Statement
        Statement statement = con.createStatement();
        //发送sql 插入值写死了
        String sql = "insert into student (id,name,age,hiretime,time) " +
                " values (null,'玫瑰之恋',12,now(),'2008-07-28')";
        statement.execute(sql);
        //处理结果
        System.out.println("Insert Ok");
        //释放资源
        statement.close();
        con.close();
    }
    void g(String str,Object... sum){
        g("伍鸿杰","a",1,'c',19.6D,10L);
    }


}
